#!/bin/bash

# Set package name, version and release
PKG_NAME=monitx
PKG_VERSION=1.1.2
PKG_RELEASE=1

# Set file paths
EXECUTABLE=/home/pywork/performance_monitor/dist/monitx
SPEC_FILE=${PKG_NAME}.spec
RPM_DIR=~/rpmbuild
SOURCES_DIR=${RPM_DIR}/SOURCES
SPECS_DIR=${RPM_DIR}/SPECS

# Create rpm directories
mkdir -p ${SOURCES_DIR} ${SPECS_DIR}

# Create spec file
cat > ${SPECS_DIR}/${SPEC_FILE} << EOF
Name: ${PKG_NAME}
Version: ${PKG_VERSION}
Release: ${PKG_RELEASE}%{?dist}
Summary: Performance monitor tool
License: MIT
URL: https://gitee.com/FrancizTest_admin/performance_monitor
Source0: ${PKG_NAME}

%description
Monitx is a tool for monitoring system performance.

%install
mkdir -p %{buildroot}/usr/local/bin/
cp %{SOURCE0} %{buildroot}/usr/local/bin/

%files
/usr/local/bin/monitx

%changelog
* Tue Mar 22 2023 John Doe <john.doe@example.com> - 1.0-1
- Initial release of the software package
- Includes basic features and functionality
- Supports running on Linux, Windows, and MacOS systems
EOF

# Copy executable to sources directory
cp ${EXECUTABLE} ${SOURCES_DIR}/${PKG_NAME}

# Build rpm package
rpmbuild -bb ${SPECS_DIR}/${SPEC_FILE}

